package Statistics;


import java.util.ArrayList;

import Definitions.GraphClass;
import Definitions.NodeClass;
import Global.GlobalClass;
import Utility.WorkerUtilityClass;

public class contentInfoExtractorClass {
	
	GraphClass currentGraph;
	GlobalClass global;
	
	contentInfoExtractorClass(GraphClass graph, GlobalClass global)
	{		
		currentGraph = graph;		
		this.global = global;
	}
	
	int getNumberOfContentFeatures()
	{
		return currentGraph.getDataSet().get(0).getContentList().get(0).getAttributeList().size();		
	}
	
	int getNumberOfClasses()
	{
		return global.classList.size();		
	}
	
	void calculateFrequencyOfTheClasses()
	{
		global.frequencyOfEachClass = new int[getNumberOfClasses()];
		
		System.out.println("# of frequencyOfEachClass: " + global.frequencyOfEachClass.length);
		
		ArrayList <NodeClass> dataset= currentGraph.getDataSet();
				
		for(int i=0; i< dataset.size(); i++)
		{
			if(dataset.get(i).getClassOrder()<getNumberOfClasses())
				global.frequencyOfEachClass[dataset.get(i).getClassOrder()]++;
			else
				System.out.println("getClassOrder() HATALI: " + dataset.get(i).getClassOrder());
			
		}				
	}	
	
	void printInfoAboutContent()
	{	
		calculateFrequencyOfTheClasses();	
		
		WorkerUtilityClass.printSeperator();
		System.out.println("# of Nodes: " + currentGraph.getDataSet().size());
		
		WorkerUtilityClass.printSeperator();		
		System.out.println("# of Content Features: " + getNumberOfContentFeatures());
		
		WorkerUtilityClass.printSeperator();		
		System.out.println("# of Classes:" + global.classList.size());
  	  	for(int i=0; i<getNumberOfClasses(); i++)
  	  	{
  	  		System.out.print("Class "+i+": "+global.classList.get(i).getName());	    		  
  	  		System.out.println(" ("+global.frequencyOfEachClass[i]+")");
  	  	}
  	  	
  	  WorkerUtilityClass.printSeperator();
	}
}
